package com.xuesinuo.ots.util;

import java.util.ArrayList;
import java.util.List;

public class ParamUtil {

    /** 转换失败，返回null。不会返回空数组 */
    public static <T extends Enum<T>> List<T> stringList2EnumList(String str, Class<T> enumClass) {
        if (StringUtil.isBlank(str)) {
            return null;
        }
        List<T> result = new ArrayList<>();
        for (String item : str.split(",")) {
            try {
                result.add(Enum.valueOf(enumClass, item));
            } catch (Exception e) {}
        }
        if (result.isEmpty()) {
            return null;
        }
        return result;
    }
}
